package com.tzg157.fitness.service.realtime.ods;

import cn.hutool.json.JSONObject;
import com.tzg157.fitness.service.realtime.HiveOnSparkService;
import org.apache.spark.sql.SparkSession;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service("odsCourseReserveService")
public class ODSCourseReserveServiceImpl implements HiveOnSparkService {
    @Override
    public void save(JSONObject jsonObject, SparkSession spark) {
        String username = (String) ((Map)jsonObject.get("data")).get("username");
        String gender = (String) ((Map)jsonObject.get("data")).get("gender");
        Integer age = (Integer) ((Map)jsonObject.get("data")).get("age");
        String timestamp_ = (String) jsonObject.get("timestamp_");
//        spark.sql("use fitness");
        spark.sql("insert into fitness.ods_member_info values('"+username+"','"+gender+"',"+age+",'"+timestamp_+"')");
    }
}
